package atguigu2.base;

import java.util.Arrays;

/**
 * @AUTHOR LYF
 * @DATE 2022/2/3
 * @VERSION 1.0
 * @DESC
 * 1. 多线程的基础(线程，进程，管程）
 * 2. 守护线程和用户线程
 * 3. 线程的状态，sleep,wait
 *
 */
public class Main {
    public static void main(String[] args) throws InterruptedException {
        // 打印多程序的状态
        Thread.State[] states = Thread.State.values();
        Arrays.stream(states).forEach(state -> System.out.println(state.name()));

        // 创建方式:三种方式
        Thread thread = new Thread(()->{
            System.out.println(Thread.currentThread().getName()+":"+Thread.currentThread().isDaemon());
        },"Thread-test");
        thread.setDaemon(true);//设置为守护线程:区分守护线程和用户线程的区别;
        thread.start();

        // sleep与wait
        String str = "hello";
        System.out.println(System.currentTimeMillis());
        str.wait(1000);// wait如何使用？
        System.out.println(System.currentTimeMillis());
        Thread.sleep(1000);
        System.out.println(System.currentTimeMillis());
    }
}
